package Calc;

public class Calculator {	
	
	private final static int humDes = 0;
	private final static int humCru = 1;
	private final static int humSco = 2;
	private final static int humBom = 3;
	private final static int humFac = 4;
	private final static int azDes = 5;
	private final static int azCru = 6;
	private final static int azSco = 7;
	private final static int azBom = 8;
	private final static int azFac = 9;
	private final static int xilDes = 10;
	private final static int xilCru = 11;
	private final static int xilSco = 12;
	private final static int xilBom = 13;
	private final static int xilFac = 14;

	public String calculate(String input) {
		String[] fields = input.split(":");
		String output = "";
		output += "" + humDesTime(fields[humFac], fields[humDes]) + ":";
		output += "" + humCruTime(fields[humFac], fields[humCru]) + ":";
		output += "" + humScoTime(fields[humFac], fields[humSco]) + ":";
		output += "" + humBomTime(fields[humFac], fields[humBom]) + ":";
		output += "" + humFacTime(fields[humFac]) + ":";
		output += "" + humFP(fields[humDes], fields[humCru], fields[humSco], fields[humBom]) + ":";
		output += "" + azDesTime(fields[azFac], fields[azDes]) + ":";
		output += "" + azCruTime(fields[azFac], fields[azCru]) + ":";
		output += "" + azScoTime(fields[azFac], fields[azSco]) + ":";
		output += "" + azBomTime(fields[azFac], fields[azBom]) + ":";
		output += "" + azFacTime(fields[azFac]) + ":";
		output += "" + azFP(fields[azDes], fields[azCru], fields[azSco], fields[azBom]) + ":";
		output += "" + xilDesTime(fields[xilFac], fields[xilDes]) + ":";
		output += "" + xilCruTime(fields[xilFac], fields[xilCru]) + ":";
		output += "" + xilScoTime(fields[xilFac], fields[xilSco]) + ":";
		output += "" + xilBomTime(fields[xilFac], fields[xilBom]) + ":";
		output += "" + xilFacTime(fields[xilFac]) + ":";	
		output += "" + xilFP(fields[xilDes], fields[xilCru], fields[xilSco], fields[xilBom]) + ":";
		output += "" + upkeep(fields[humDes], fields[humCru], fields[humSco], fields[humBom], fields[azDes], fields[azCru], fields[azSco], fields[azBom], fields[xilDes], fields[xilCru], fields[xilSco], fields[xilBom]) + ":";
		output += "" + carry(fields[humDes], fields[humCru], fields[humSco], fields[humBom], fields[azDes], fields[azCru], fields[azSco], fields[azBom], fields[xilDes], fields[xilCru], fields[xilSco], fields[xilBom]) + ":";
		output += "" + (humFP(fields[humDes], fields[humCru], fields[humSco], fields[humBom]) + azFP(fields[azDes], fields[azCru], fields[azSco], fields[azBom]) + xilFP(fields[xilDes], fields[xilCru], fields[xilSco], fields[xilBom]));
		return output;
	}
	
	private String humDesTime(String fac, String des) {
		double facs = Double.parseDouble(fac);
		double dess = Double.parseDouble(des);		
		return "" + (Math.ceil(dess/(facs * 0.350)));
	}
	
	private String humCruTime(String fac, String cru) {
		double facs = Double.parseDouble(fac);
		double crui = Double.parseDouble(cru);		
		return "" + (Math.ceil(crui/(facs * 0.057)));
	}
	
	private String humScoTime(String fac, String sco) {
		double facs = Double.parseDouble(fac);
		double scou = Double.parseDouble(sco);		
		return "" + (Math.ceil(scou/(facs * 1.450)));
	}
	
	private String humBomTime(String fac, String bom) {
		double facs = Double.parseDouble(fac);
		double bomb = Double.parseDouble(bom);		
		return "" + (Math.ceil(bomb/(facs * 0.294)));
	}
	
	private String humFacTime(String fac) {
		double facs = Double.parseDouble(fac);				
		return "" + (Math.floor(facs / (1 / 0.100)));
	}
	
	private double humFP(String des, String cru, String sco, String bom) {
		double dess = Double.parseDouble(des);
		double crui = Double.parseDouble(cru);		
		double scou = Double.parseDouble(sco);		
		double bomb = Double.parseDouble(bom);		
		return ((dess * 56) + (crui * 319) + (scou * 8) + (bomb * 34));
	}
	
	private String azDesTime(String fac, String des) {
		double facs = Double.parseDouble(fac);
		double dess = Double.parseDouble(des);		
		return "" + (Math.ceil(dess/(facs * 0.182)));
	}
	
	private String azCruTime(String fac, String cru) {
		double facs = Double.parseDouble(fac);
		double crui = Double.parseDouble(cru);		
		return "" + (Math.ceil(crui/(facs * 0.028)));
	}
	
	private String azScoTime(String fac, String sco) {
		double facs = Double.parseDouble(fac);
		double scou = Double.parseDouble(sco);		
		return "" + (Math.ceil(scou/(facs * 1.167)));
	}
	
	private String azBomTime(String fac, String bom) {
		double facs = Double.parseDouble(fac);
		double bomb = Double.parseDouble(bom);		
		return "" + (Math.ceil(bomb/(facs * 0.210)));
	}
	
	private String azFacTime(String fac) {
		double facs = Double.parseDouble(fac);				
		return "" + (Math.floor(facs / (1 / 0.089)));
	}
	
	private double azFP(String des, String cru, String sco, String bom) {
		double dess = Double.parseDouble(des);
		double crui = Double.parseDouble(cru);		
		double scou = Double.parseDouble(sco);		
		double bomb = Double.parseDouble(bom);		
		return ((dess * 73) + (crui * 393) + (scou * 6) + (bomb * 67));
	}
	
	private String xilDesTime(String fac, String des) {
		double facs = Double.parseDouble(fac);
		double dess = Double.parseDouble(des);		
		return "" + (Math.ceil(dess/(facs * 0.112)));
	}
	
	private String xilCruTime(String fac, String cru) {
		double facs = Double.parseDouble(fac);
		double crui = Double.parseDouble(cru);		
		return "" + (Math.ceil(crui/(facs * 0.016)));
	}
	
	private String xilScoTime(String fac, String sco) {
		double facs = Double.parseDouble(fac);
		double scou = Double.parseDouble(sco);		
		return "" + (Math.ceil(scou/(facs * 0.732)));
	}
	
	private String xilBomTime(String fac, String bom) {
		double facs = Double.parseDouble(fac);
		double bomb = Double.parseDouble(bom);		
		return "" + (Math.ceil(bomb/(facs * 0.144)));
	}
	
	private String xilFacTime(String fac) {
		double facs = Double.parseDouble(fac);				
		return "" + (Math.floor(facs / (1 / 0.112)));
	}
	
	private double xilFP(String des, String cru, String sco, String bom) {
		double dess = Double.parseDouble(des);
		double crui = Double.parseDouble(cru);		
		double scou = Double.parseDouble(sco);		
		double bomb = Double.parseDouble(bom);		
		return ((dess * 67) + (crui * 475) + (scou * 7) + (bomb * 40));
	}
	
	private String upkeep(String hd, String hc, String hs, String hb, String ad, String ac, String as, String ab, String xd, String xc, String xs, String xb) {
		double hdes = Double.parseDouble(hd);
		double hcru = Double.parseDouble(hc);
		double hsco = Double.parseDouble(hs);
		double hbom = Double.parseDouble(hb);
		double ades = Double.parseDouble(ad);
		double acru = Double.parseDouble(ac);
		double asco = Double.parseDouble(as);
		double abom = Double.parseDouble(ab);
		double xdes = Double.parseDouble(xd);
		double xcru = Double.parseDouble(xc);
		double xsco = Double.parseDouble(xs);
		double xbom = Double.parseDouble(xb);
		double des = hdes + ades + xdes;
		double cru = hcru + acru + xcru;
		double sco = hsco + asco + xsco;
		double bom = hbom + abom + xbom;
		double total = (des * 1000) + (cru * 7200) + (sco * 150) + (bom * 1000);
		return "" + total;		
	}
	
	private String carry(String hd, String hc, String hs, String hb, String ad, String ac, String as, String ab, String xd, String xc, String xs, String xb) {
		double hdes = Double.parseDouble(hd);
		double hcru = Double.parseDouble(hc);
		double hsco = Double.parseDouble(hs);
		double hbom = Double.parseDouble(hb);
		double ades = Double.parseDouble(ad);
		double acru = Double.parseDouble(ac);
		double asco = Double.parseDouble(as);
		double abom = Double.parseDouble(ab);
		double xdes = Double.parseDouble(xd);
		double xcru = Double.parseDouble(xc);
		double xsco = Double.parseDouble(xs);
		double xbom = Double.parseDouble(xb);
		double des = hdes + ades + xdes;
		double cru = hcru + acru + xcru;
		double sco = hsco + asco + xsco;
		double bom = hbom + abom + xbom;
		double total = (des * 1) + (cru * 1) + (sco * 0) + (bom * 5);
		return "" + total;		
	}
}
